package com.jbit.dm212.common;

import com.jbit.dm212.entity.po.DmSchedulerSeat;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class OrderUtil {
    public static String generateOrderNo(){
        String orderNo = DateUtil.format("yyyyMMddHHmmssms");
        orderNo += (int) (Math.random() * (1000-100) + 100);
        return orderNo;
    }

    public static String generateInvoiceNo(){
        String invoiceNo = "NDLDFSD";
        //
        Random random = new Random();
        for (int i = 0; i < 10; i++) {
            invoiceNo += random.nextInt(10);
        }
        return invoiceNo;
    }

    public static Double getMoneyByInsurance(Integer isNeedInsurance){
        if (isNeedInsurance == 1){
            return 20.0;
        }else{
            return 0.0;
        }
    }

    public static List<DmSchedulerSeat> getSeatInfo(String [] seatArray,Integer scheduleId){
        List<DmSchedulerSeat> schedulerSeatList = new ArrayList<>();
        for (String s : seatArray) {
            DmSchedulerSeat schedulerSeat = new DmSchedulerSeat();
            schedulerSeat.setScheduleId(scheduleId);
            String []seats = s.split("_");
            schedulerSeat.setX(Integer.parseInt(seats[0]));
            schedulerSeat.setY(Integer.parseInt(seats[1]));
            schedulerSeatList.add(schedulerSeat);
        }
        return schedulerSeatList;
    }
}
